﻿Imports System.Data.OleDb
Module config
    Public Class C_config

        'Obtengo la configuracion desde la base de datos
        Public Function GetConfig() As OleDbDataReader
            Using cadenaConexBD()
                Dim drconfig As OleDbDataReader
                Dim instruccion As New OleDbCommand("SELECT * FROM config", cadenaConexBD)
                drconfig = instruccion.ExecuteReader()
                Return drconfig
                drconfig.Close()
            End Using

        End Function

        'Guardar configuracion
        Public Sub updateConfig()
            Try
                Using cadenaConexBD()
                    Dim updateConfig As New OleDbCommand("UPDATE config SET config.encabezado='" & frmConfig.rtEncabezado.Text & "',config.firma='" & frmConfig.rtFirma.Text & "',config.email='" & frmConfig.txtEmailUser.Text & "',config.password='" & frmConfig.txtPassEmail.Text & "',config.smtp='" & frmConfig.txtSmtp.Text & "',config.port='" & frmConfig.txtPort.Text & "' WHERE id_config = 1 ", cadenaConexBD)
                    updateConfig.ExecuteNonQuery()
                End Using
                MessageBox.Show("El registro ah sido modificado con exito", "Configuracion Guardada", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub



    End Class
End Module
